package com.djk.daily.threadpool;

import java.util.Timer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * newFixedThreadPool内存溢出情况
 */
public class FixedThreadPoolOom {
    private static ExecutorService executorService = Executors.newFixedThreadPool(1);
    public static void main(String[] args) {
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            executorService.execute(new SubTask());
        }
    }
}

class SubTask implements Runnable{
    @Override
    public void run() {
        try {
            TimeUnit.SECONDS.sleep(10000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
